#include "cpu/exec/template-start.h"

#define instr div

static void do_execute() {
	uint64_t a;		//存储被除数
	uint32_t b = (DATA_TYPE)op_src->val;	//源操作数转换为32位无符号整数
	//根据字节大小选择处理方式
#if DATA_BYTE == 1
	a = reg_w(R_EAX);	//数据字节为1，仅用EAX
#else
	//数据字节为2或4，将EDX和EAX组合为一个64位被除数
	a = ((uint64_t)REG(R_EDX) << (DATA_BYTE * 8)) | REG(R_EAX);
#endif
	REG(R_EAX) = a / b;		//EAX:商
	REG(R_EDX) = a % b;		//EDX:余数

	print_asm_template1();
}

make_instr_helper(rm)

#include "cpu/exec/template-end.h"
